package org.korifey.ffbdd.api.deprecated;

import org.korifey.ffbdd.api.INode;
import org.korifey.ffbdd.api.op.IBinaryOperation;

public class CacheKey {

	public static class BinopKey {
		INode n1;
		INode n2;
		IBinaryOperation op;
		
		public BinopKey(INode n1, INode n2, IBinaryOperation op) {
			super();
			this.n1 = n1;
			this.n2 = n2;
			this.op = op;
		}
	
		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + ((n1 == null) ? 0 : n1.hashCode());
			result = prime * result + ((n2 == null) ? 0 : n2.hashCode());
			result = prime * result + ((op == null) ? 0 : op.hashCode());
			return result;
		}
	
		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			BinopKey other = (BinopKey) obj;
			if (n1 == null) {
				if (other.n1 != null)
					return false;
			} else if (!n1.equals(other.n1))
				return false;
			if (n2 == null) {
				if (other.n2 != null)
					return false;
			} else if (!n2.equals(other.n2))
				return false;
			if (op == null) {
				if (other.op != null)
					return false;
			} else if (!op.equals(other.op))
				return false;
			return true;
		}
	}

	public static class ITEKey {
		INode n1, n2, n3;
	
		public ITEKey(INode n1, INode n2, INode n3) {
			super();
			this.n1 = n1;
			this.n2 = n2;
			this.n3 = n3;
		}
	
		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + ((n1 == null) ? 0 : n1.hashCode());
			result = prime * result + ((n2 == null) ? 0 : n2.hashCode());
			result = prime * result + ((n3 == null) ? 0 : n3.hashCode());
			return result;
		}
	
		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			ITEKey other = (ITEKey) obj;
			if (n1 == null) {
				if (other.n1 != null)
					return false;
			} else if (!n1.equals(other.n1))
				return false;
			if (n2 == null) {
				if (other.n2 != null)
					return false;
			} else if (!n2.equals(other.n2))
				return false;
			if (n3 == null) {
				if (other.n3 != null)
					return false;
			} else if (!n3.equals(other.n3))
				return false;
			return true;
		}
	}

}
